<?php

class Subject_m extends CI_Model{
    function __construct() {
        parent::__construct();
        $this->load->database();
    }
    
    function insert($arr){
        $this->db->insert('subject',$arr);
    }
    
    function update($id,$arr){
        $this->db->where('id',$id);
        $this->db->update('subject',$arr);
    }
    
    function delete($id){
        $this->db->where('id',$id);
        $this->db->delete('subject');
    }
    
    function select($arr){
        $this->db->where($arr);
        $this->db->select('*');
        $query=$this->db->get('subject');
        return $query->result();
    }
    
    function getdetail($sid)
    {
        $this->db->where('subjectId',$sid);
        $this->db->select('chapter.*,task.id as taskid,task.name as taskname');
        $this->db->join('task','chapter.id=task.chapterid','left');
        $query=$this->db->get('chapter');
        return $query->result();
    }
}

